<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/23
 * Time: 10:56
 */

namespace app\admin\model;


class SignRule extends DataBase
{
    protected $name = 'sign_rule';
    protected $autoWriteTimestamp = true;

//    public function getRewardTypeAttr($value)
//    {
//        $status = [1=>'金币','钻石','座驾','礼物','喇叭','生肖卡'];
//        if(sizeof($status) < $value)
//            return '自定义';
//        return $status[$value];
//     }
    public function getDataList()
    {
        $page_config = array(
            'page' => input('get.offset',1),
            'list_rows' => input('get.limit',10)
        );
        $where = [];
        $key = input('key');
        $value = input('value');
        if(!empty($key) && !empty($value)){
                $where[] = [$key,'=',$value];
        }
        $order = input('sort','id').' '.input('order','asc');
        $data = $this->where($where)->order($order)->paginate($page_config);
        foreach($data as $key => $value){
            $reward_type = $value['reward_type'];
            switch($reward_type){
                case 3: $data[$key]['reward_id'] = Vehicle::where('vehicle_id','=',$value['reward_id'])->value('vehicle_name');break;
                case 4: $data[$key]['reward_id'] = Gift::where('id','=',$value['reward_id'])->value('gift_name');break;
                case 5: $data[$key]['reward_id'] = ShopHorn::where('horn_id','=',$value['reward_id'])->value('horn_name');break;
                case 6: $data[$key]['reward_id'] = Card::where('id','=',$value['reward_id'])->value('name');break;
                default:$data[$key]['reward_id'] = '钻石或金币或自定义奖品';
            }
        }
        return $data;
    }
}